package com.baor.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baor.dao.StopDao;
import com.baor.domain.StopVo;
import com.baor.service.StopService;
import com.baor.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class StopServiceImpl implements StopService {

    @Autowired
    private StopDao stopDao;


    @Override
    public AjaxResult<?> list() {
        return AjaxResult.success(stopDao.selectList(null));
    }

    @Override
    public AjaxResult<?> search(StopVo stopVo) {
        LambdaQueryWrapper<StopVo> wrapper = new LambdaQueryWrapper<StopVo>();
        if ( stopVo.getStopParking() != null && ! "".equals(stopVo.getStopParking()) )
            wrapper.eq(StopVo::getStopParking,stopVo.getStopParking());
        if ( stopVo.getStopCooperate() != null && ! "".equals(stopVo.getStopCooperate()) )
            wrapper.eq(StopVo::getStopCooperate,stopVo.getStopCooperate());
        if ( stopVo.getStopLicense() != null && ! "".equals(stopVo.getStopLicense()) )
            wrapper.like(StopVo::getStopLicense,stopVo.getStopLicense());
        if ( stopVo.getStopEntrytime() != null && ! "".equals(stopVo.getStopEntrytime()) )
            wrapper.gt(StopVo::getStopEntrytime,stopVo.getStopEntrytime());//>
        if ( stopVo.getStopOuttime() != null && ! "".equals(stopVo.getStopOuttime()) )
            wrapper.lt(StopVo::getStopOuttime,stopVo.getStopOuttime());//<
        List<StopVo> stopVos = stopDao.selectList(wrapper);
        return AjaxResult.success(stopVos);
    }
}
